package com.fly.flowdemo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.fly.flowdemo.view.MulButtonFlowLayout;
import com.fly.flowdemo.view.SingleButtonFlowLayout;

import java.util.List;

public class MainActivity extends AppCompatActivity {

    static final String[] labels = {
            "java", "C", "C++", "php", "swift", "Object-C", "HTML5", "CSS3"
    };
    /*static final String[] labels = {
            "java", "C", "C++", "php", "swift", "Object-C"
    };*/

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        SingleButtonFlowLayout btnFlow = (SingleButtonFlowLayout) findViewById(R.id.id_btn_flow);
        btnFlow.setLabels(labels);
        btnFlow.setDefaultChoose(labels.length - 1);
        btnFlow.setOnItemClickListener(new SingleButtonFlowLayout.OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {
                Log.e("tag", ((Button)view).getText() + " [ " + position + " ]");
            }
        });
        final MulButtonFlowLayout mBtnFlow = (MulButtonFlowLayout) findViewById(R.id.id_mul_btn_flow);
        mBtnFlow.setLabels(labels);
        mBtnFlow.setOnItmChoosedListener(new MulButtonFlowLayout.OnItemChoosedListener() {
            @Override
            public void onItemChoosed(List<View> views, List<Integer> positions) {
                Log.e("tag", views.size() + " ]");
                for (int position : positions) {
                    Log.e("tag", "[ " + position + " ]");
                }
            }
        });

        findViewById(R.id.id_clear_mul).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mBtnFlow.clearChooseStatus();
            }
        });
    }

}
